package cn.qyd.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @author 邱运铎
 * 模拟一个简单的web服务器，接收和处理请求
 * @date 2024-03-23 0:09
 */
public class SimpleWebServer {
    private final static int NTHREADS = 100;
    private final static ExecutorService pool = Executors.newFixedThreadPool(NTHREADS);

    public static void main(String[] args) {
        while (true) {
            //接受请求
            Runnable request = new Runnable() {
                @Override
                public void run() {
                    //处理请求
                    System.out.println(Thread.currentThread().getName() + " 正在处理请求。。。。");
                }
            };

            pool.execute(request);
        }
    }
}
